package com.yizhu.zczy.system.controller;

import java.util.Arrays;
import java.util.Map;


import com.yizhu.zczy.common.utils.PageUtils;
import com.yizhu.zczy.common.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.yizhu.zczy.system.entity.ServiceEntity;
import com.yizhu.zczy.system.service.ServiceService;
import org.springframework.web.multipart.MultipartFile;


/**
 * 客服表
 *
 * @author guoyz
 * @email guoyz@mail.com
 * @date 2021-06-24 18:29:34
 */
@RestController
@RequestMapping("system/service")
public class ServiceController {
    @Autowired
    private ServiceService serviceService;

    /**
     * 列表
     */
    @GetMapping("/list")
    //@RequiresPermissions("system:service:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = serviceService.queryPage(params);
        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    //@RequiresPermissions("system:service:info")
    public R info(@PathVariable("id") Integer id){
		ServiceEntity service = serviceService.getById(id);

        return R.ok().put("service", service);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    public R save(ServiceEntity service, MultipartFile weChatPicture){
		serviceService.saveService(service,weChatPicture);
        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("system:service:update")
    public R update(ServiceEntity service){
		serviceService.updateById(service);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("system:service:delete")
    public R delete(@RequestBody Integer[] ids){
		serviceService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
